home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / redo / redoUnMarkLargeObjOnPage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  5.3 KB  |  205 lines

  1. /*
  2.  *   $RCSfile: redoUnMarkLargeObjOnPage.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:58 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38.  
  39. #include "sysdefs.h"
  40. #include "ess.h"
  41. #include "checking.h"
  42. #include "trace.h"
  43. #include "error.h"
  44. #include "list.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "latch.h"
  52. #include "semaphore.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "log.h"
  57. #include "pool.h"
  58. #include "volume.h"
  59. #include "logrecs.h"
  60. #include "trans.h"
  61. #include "bitmap.h"
  62. #include "file.h"
  63. #include "openlog.h"
  64. #include "bf_extfuncs.h"
  65. #include "bm_extfuncs.h"
  66. #include "fi_intfuncs.h"
  67. #include "trans_extfuncs.h"
  68. #include "redo_extfuncs.h"
  69. #include "logaction.h"
  70. #include "util_funcs.h"
  71. #include "thread_globals.h"
  72. #include "bf_globals.h"
  73. #include "log_globals.h"
  74. #include "log_extfuncs.h"
  75.  
  76.  
  77.  void
  78. redoUnMarkLargeObjOnPage (
  79.  
  80.     LOGRECORDHDR        *record 
  81. )
  82. {
  83.  
  84.     register PID        *pid;
  85.     register FOUR        *foundLoc;
  86.     register SHORTPID    *key;
  87.     register NODEPAGE    *nodePage;
  88.     register GROUPLINK    *nodeLink;
  89.     DIRTYPAGEINFO        *dirtyInfo;
  90.     SHORTPID            *gotPid;
  91.  
  92.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
  93.  
  94.     /*
  95.      *    get a pointer to the name in the record
  96.      */
  97.     pid = &(record->actionPid);
  98.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
  99.  
  100.     /*
  101.      *    get a pointer to the found location in the record
  102.      */
  103.     foundLoc = (FOUR *) GET_LOG_IMAGE(record, 0);
  104.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("foundLoc:%d", *foundLoc));
  105.  
  106.     /*
  107.      *    get a pointer to the key inserted in the record
  108.      */
  109.     key = (SHORTPID *) GET_LOG_IMAGE(record, 1);
  110.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("key:%d", *key));
  111.  
  112.     /*
  113.      *    check to see if the page is in the dirty page list
  114.      */
  115.     if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL)    {
  116.  
  117.         /*
  118.          *    don't need to redo
  119.          */
  120.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
  121.         return;
  122.     }
  123.  
  124.     /*
  125.      *  check to see if the lrc on the page is greater than
  126.      *  the lrc in the log record.
  127.      *  Also check the lsn for the case of pages which never made it
  128.      *  back from the client.
  129.      */
  130.     if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
  131.  
  132.         /*
  133.          *  don't need to redo
  134.          */
  135.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
  136.         return;
  137.     }
  138.  
  139.     /*
  140.      * Read in first page of file and grab node type
  141.      */
  142.     if ((nodeLink = bf_ReadPage(UserBufGroup, pid, FILE_PAGE2SIZE, BF_SEM)) == NULL) {
  143.  
  144.         SM_ERROR(TYPE_FATAL, Active->errno);
  145.     }
  146.  
  147.     /*
  148.      *    get a pointer to the node page
  149.      */
  150.     nodePage = (NODEPAGE *) nodeLink->bufFrame;
  151.  
  152.     /*
  153.      *  check to see if the lsn on the page is greater than
  154.      *  the lrc in the log record
  155.      */
  156.     if (compareLRC( &(record->actionLRC), &(nodePage->header.lrc)) <= 0) {
  157.  
  158.         /*
  159.          *  don't need to redo
  160.          *  mark the page lrc
  161.          */
  162.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
  163.         dirtyInfo->lrc = nodePage->header.lrc;
  164.  
  165.         /*
  166.          *    release the page
  167.          */
  168.         signalSemaphore( &(nodeLink->pageHash->semaphore) );
  169.         bf_UnfixPage(nodeLink, BF_DEFAULT, FALSE);
  170.         return;
  171.     }
  172.  
  173.     /*
  174.      *  extract the pid from the page, making sure the page
  175.      *    is already marked as having a large object, and that
  176.      *    the page is the correct one
  177.      */
  178.     gotPid = &(nodePage->contents.keyPid.allKeys[*foundLoc].key);
  179.     SM_ASSERT(LEVEL_3, (*gotPid & SETLARGE));
  180.     SM_ASSERT(LEVEL_3, (*gotPid & LARGEMASK) == *key);
  181.  
  182.     /*
  183.      *    redo the unmarking
  184.      */
  185.     *gotPid &= ~SETLARGE;
  186.  
  187.     /*
  188.      *    mark the lrc on the page
  189.      *    Set up the firstLSN/LRC for the page
  190.      */
  191.     nodePage->header.lrc = record->actionLRC;
  192.     DEPEND_LOG(nodeLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
  193.     TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", nodePage->header.lrc.count));
  194.  
  195.     /*
  196.      *    release  the page semaphore
  197.      */
  198.     signalSemaphore( &(nodeLink->pageHash->semaphore) );
  199.  
  200.     /*
  201.      *    release and dirty the page
  202.      */
  203.     bf_UnfixPage(nodeLink, BF_DEFAULT, TRUE);
  204. }
  205.